﻿using System;
using System.Web.UI;
using BLL;
using Entity;
using Web.Class;

namespace Web.Pages.YongShui._15.BaoBiaoGL.DanJuDY
{
    public partial class JiHuaZXQKGZ : Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                InitData();
            }
        }

        protected void btnSearch_OnClick(object sender, EventArgs e)
        {
            if (txtYonghuh.Text == "")
            {
                txtYonghuh.Focus();
                return;
            }
            if (txtYearMonth.Text == "")
            {
                txtYearMonth.Focus();
                return;
            }
            var userData = new SqlHelper().GetYongHuZXQK(txtYonghuh.Text, txtYearMonth.Text,null).Tables[0];
            if (userData.Rows.Count == 0)
            {
                PageTools.AlertMsg(this,"未找到用户数据");
            }
            else
            {
                txtJiHuaL.Text = userData.Rows[0]["I_YUANJIHUA"].ToString();
                txtYonghuMing.Text = userData.Rows[0]["S_YONGHUM"].ToString();
                txtJiaJiaJE.Text = userData.Rows[0]["N_JIAJIAJE"].ToString();
                txtJiaJiaL.Text = userData.Rows[0]["I_JIAJIAL"].ToString();
                txtShiYongL.Text = userData.Rows[0]["I_SHIYONGSL"].ToString();
                txtYonghuh2.Text = userData.Rows[0]["I_YUANJIHUA"].ToString();
                txtYear.Text = userData.Rows[0]["I_Y"].ToString();
                txtMonth.Text = userData.Rows[0]["I_M"].ToString();
            }
        }

        private void InitData()
        {
            var waterYM = BusinessTool.YS_GETSETTINGSVALUE(eSETTINGS_KEYNAME.WATER_Y_M.ToString());
            txtYearMonth.Text = waterYM;
            txtPrintDate.Text = DateTime.Now.ToString("yyyy-MM-dd");
        }
    }
}